package com.example.jsd2205.vx.emos.controller;


import com.example.jsd2205.vx.emos.common.util.R;
import com.example.jsd2205.vx.emos.controller.form.TestSayHelloForm;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 关于Swagger的测试方法
 * 测试封装R对象返回消息
 */
@RestController
@RequestMapping("/test")
@Api("测试web接口")//作用,Swagger扫描Web方法
public class TestController {
    /**
     * 测试返回的消息
     * @return R
     */
    @PostMapping("/sayHello")
    @ApiOperation("最简单的测试方法")
    public R sayHello(@Valid @RequestBody TestSayHelloForm form){
        return R.ok().put("message,","Hello!"+form.getName());
    }

    @PostMapping("/addUser")
    @ApiOperation("添加用户")
    @RequiresPermissions(value = {"A","B"},logical = Logical.OR)
    public R addUser(){
        return R.ok("用户添加成功");
    }

}
